var ajaxHelper = require("../../utils/ajaxhelp");
const serviceUrl = getApp().globalData.serviceUrl;
let token = wx.getStorageSync('token');

const getClassByPAC = (provinceName, cityName, areaName) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Class/GetClassByProviceCityCounty", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		province: provinceName,
		city: cityName,
		area: areaName
	})
}
const getClassByPACAndName = (provinceName, cityName, areaName, classname, stage, schoolid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Class/GetClassByName", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		province: provinceName,
		city: cityName,
		area: areaName,
		className: classname,
		stage: stage,
		schoolid: schoolid
	})
}
const getClassById = (id) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Class/GetClassById", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		classId: id
	})
}
const modClassById = (calssinfo = {}) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Class/Post", {
		'Authorization': 'Bearer ' + token
	}, "POST", calssinfo)
}
const addClass = (classinfo = {}) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Class/Put", {
		'Authorization': 'Bearer ' + token
	}, "Post", classinfo)
}
const getSchoolListByType = (school = {}) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/School/GetSchool", {
		'Authorization': 'Bearer ' + token
	}, "GET", school)
}
const QueryClassByPCAandStageSchool = (provinceName, cityName, areaName, stage, schoolid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Class/QueryClassByPCAandStageSchool", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		province: provinceName,
		city: cityName,
		area: areaName,
		stage: stage,
		schoolid: schoolid
	})
}
//根据学校id或者班级名称获取班级
const QueryClassBySchoolIdAndClassName = (schoolId, classname = "") =>{
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Class/QueryClassBySchoolIdAndClassName", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		schoolId: schoolId,
		classname: classname
	})
}
module.exports = {
	getClassByPAC,
	getClassByPACAndName,
	getClassById,
	modClassById,
	getSchoolListByType,
	addClass,
	QueryClassByPCAandStageSchool,
	QueryClassBySchoolIdAndClassName,
}
